/**
 * 
 */
package com.jie.eclipse.pan.swtitem.actiongroup;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.viewers.CheckboxTableViewer;

import com.jie.eclipse.pan.data.BaseDataEntity;
import com.jie.eclipse.pan.swtitem.widgets.BaseComposite;
import com.jie.eclipse.pan.utils.Utils;
import com.jie.eclipse.pan.utils.handle.FileHandle;

/**
 * @author yanjie
 *
 */
public class SeachActionGroup1 extends BaseActionGroup{
	
	
	/**
	 * @param bc
	 * @param fileHandle
	 */
	public SeachActionGroup1(BaseComposite bc, FileHandle fileHandle) {
		super(bc, fileHandle);
	}

	private class Insert1Action extends Action{
		public Insert1Action() {
			this.setImageDescriptor(getImageDesc("icon_addrow.gif"));
			this.setText("添加选择栏位");
		}
		
		@Override
		public void run() {
			CheckboxTableViewer ctv1 = (CheckboxTableViewer)getBaseComposite().getDataInstance().gpov("ctv1");//可选栏位表格选择器
			CheckboxTableViewer ctv2 = (CheckboxTableViewer)getBaseComposite().getDataInstance().gpov("ctv2");//已选栏位表格选择器
			if(ctv1 == null || ctv2 == null){
				Utils.print("表格选择器不正常");
				return;
			}
			
			for (int i = 0; i < ctv1.getCheckedElements().length; i++) {
				BaseDataEntity row = (BaseDataEntity)ctv1.getCheckedElements()[i];
				row.spsv("id", row.gpsv("cid"));
			}
			ctv2.add(ctv1.getCheckedElements());
			ctv1.remove(ctv1.getCheckedElements());
		}
	}
	
	public void fillActionToolbars (ToolBarManager actionBarManager){
		Insert1Action action1 = new Insert1Action();
		
		actionBarManager.add(createActionContributionItem(action1));		
		actionBarManager.update(true);
	}
}
